package com.ruoyi.crm.controller;

import java.util.List;

import com.ruoyi.crm.domain.CrmGhSys;
import com.ruoyi.crm.service.ICrmGhSysService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统信息Controller
 * 
 * @author ruoyi
 * @date 2023-03-30
 */
@RestController
@RequestMapping("/sysMess")
public class CrmGhSysController extends BaseController
{
    @Autowired
    private ICrmGhSysService crmGhSysService;

    /**
     * 查询系统信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:sys:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmGhSys crmGhSys)
    {
        startPage();
        List<CrmGhSys> list = crmGhSysService.selectCrmGhSysList(crmGhSys);
        return getDataTable(list);
    }

    /**
     * 导出系统信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:sys:export')")
    @Log(title = "系统信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrmGhSys crmGhSys)
    {
        List<CrmGhSys> list = crmGhSysService.selectCrmGhSysList(crmGhSys);
        ExcelUtil<CrmGhSys> util = new ExcelUtil<CrmGhSys>(CrmGhSys.class);
        return util.exportExcel(list, "sys");
    }

    /**
     * 获取系统信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sys:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(crmGhSysService.selectCrmGhSysById(userId));
    }

    /**
     * 新增系统信息
     */
    @PreAuthorize("@ss.hasPermi('system:sys:add')")
    @Log(title = "系统信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmGhSys crmGhSys)
    {
        return toAjax(crmGhSysService.insertCrmGhSys(crmGhSys));
    }

    /**
     * 修改系统信息
     */
    @PreAuthorize("@ss.hasPermi('system:sys:edit')")
    @Log(title = "系统信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmGhSys crmGhSys)
    {
        return toAjax(crmGhSysService.updateCrmGhSys(crmGhSys));
    }

    /**
     * 删除系统信息
     */
    @PreAuthorize("@ss.hasPermi('system:sys:remove')")
    @Log(title = "系统信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(crmGhSysService.deleteCrmGhSysByIds(userIds));
    }
}
